package com.kingsoft.miot.bridge.service.impl.manager;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.kingsoft.miot.bridge.dao.manager.GroupInfoDao;
import com.kingsoft.miot.bridge.exception.CommonException;
import com.kingsoft.miot.bridge.pojo.manager.GroupInfo;
import com.kingsoft.miot.bridge.service.manager.GroupInfoService;

/**
 * 角色 信息 服务
 * 
 * @author HUJIANQING
 *
 */
@Service
public class GroupInfoServiceImpl implements GroupInfoService {

	private static final Logger LOGGER = LoggerFactory.getLogger(GroupInfoServiceImpl.class);

	@Autowired
	private GroupInfoDao groupInfoDao;

	/**
	 * 获得所有角色
	 */
	@Override
	@Transactional(propagation = Propagation.SUPPORTS)
	public List<GroupInfo> findAll() {
		try {
			return groupInfoDao.findAll();
		} catch (Exception e) {
			LOGGER.error("查询所有角色失败！");
			throw new CommonException(e);
		}
	}

	/**
	 * 通过id获取信息
	 */
	@Override
	public GroupInfo getById(int group_info_id) {
		try {
			GroupInfo groupInfo = groupInfoDao.getById(group_info_id);
			return groupInfo;
		} catch (Exception e) {
			throw new CommonException(e);
		}
	}

}
